package org.example.ThreadDemo;

/**
 * @Author : zhangbo
 * @data : 2024/7/9
 * @description :
 */
public class test {
    private static final Object lock = new Object();
    public static synchronized void myTest(){
        int i=5;
        i=i+6;
        System.out.println(i);
    }

    public static void myMethod1() {
        synchronized (lock) {
            // 同步代码块
        }
    }

    public void myMethod() {
        synchronized (this) {
            // 同步代码块
        }
    }

    public static void main(String[] args) {
        myTest();
    }
}
